/*
 * util_string.h
 *
 *  Created on: Mar 23, 2012
 *      Author: lin
 */

#ifndef UTIL_STRING_H_
#define UTIL_STRING_H_

#include <string.h>
#include <assert.h>

#include "zmalloc/zmalloc.h"

char** string_split(char *str, const char *delim, int *num);

char** string_sub(const char *str, const char *delim, int *num);

static inline int string_starts_with0(const char *str, int strlen,
        const char* start, int startlen) {
    assert(strlen >= 0 && startlen >= 0);
    assert(str && start);
    return ((strlen >= startlen) && (memcmp(str, start, startlen) == 0));
}

static inline int string_starts_with1(const char *str, const char *start) {
    assert(str && start);
    return string_starts_with0(str, strlen(str), start, strlen(start));
}
#endif /* UTIL_STRING_H_ */
